use std::process::Command;

/// 新建签名密钥文件 keytool -genkey -alias debug -keypass 123456 -storepass 123456 -dname "C=CN,ST=st,L=st,O=st,OU=dev,CN=st.com" -keyalg RSA -keysize 2048 -validity 3650 -keystore debug.keystore
pub fn xin_jian_qian_min(alias: String, keystore_name: String, keystore_password: String) -> bool {
    let out = Command::new("keytool")
        .arg("-keytool")
        .arg("-alias")
        .arg(alias)
        .arg("-keypass")
        .arg(&keystore_password)
        .arg("=storepass")
        .arg(&keystore_password)
        .args([
            "-dname",
            "C=CN,ST=st,L=st,O=st,OU=dev,CN=st.com",
            "-keyalg",
            "RSA",
            "-keysize",
            "2048",
            "-validity",
            "3650",
        ])
        .arg("-keystore")
        .arg(keystore_name)
        .output()
        .expect("sh exec error!");
    let output_str = String::from_utf8_lossy(&out.stdout);
    if output_str != "" {
        return true;
    }
    false
}
/// jarsigner -keystore 密钥位置 xxx.apk 简称 -storepass 密码
pub fn apk_qian_min(alias: String, keystore_name: String, keystore_password: String) -> bool {
    let out = Command::new("jarsigner")
        .arg("-keystore")
        .arg(keystore_name)
        .arg("out.apk")
        .arg(alias)
        .arg("-storepass")
        .arg(keystore_password)
        .output()
        .expect("sh exec error!");
    let output_str = String::from_utf8_lossy(&out.stdout);
    if output_str != "" {
        return true;
    }
    false
}
